/*
    YmsgIRC - Program enabling YMSG chat clients to use IRC
    Copyright (C) 2011 Crash Daemonicus ( crashenator -at- gmail.com )

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#include "common.h"
#include "network.h"
#include "YMSG_constants.h"
#include "YMSG_field.h"
#include "YMSG_list.h"

enum YmsgObjectType
{
	YMSG_DATA,
	YMSG_FIELD,
	YMSG_ITEM,
	YMSG_LIST
};


class YmsgObject//me kind of a variant.
{
	public:
		YmsgObjectType type;
		YmsgField field;//ugly, I know - but the alternative is what? inheritance and pointer vectors for objects that shouldn't inherit?
		YmsgItem item;
		YmsgList list;

		YmsgObject(const YmsgField& fld);
		YmsgObject(const YmsgList & lst);
		YmsgObject(const YmsgItem & itm);

};

class YmsgFieldParser
{
public:
	vector<YmsgObject> filterObjects(const vector<YmsgObject>& objects,YmsgObjectType type, bool include=true);//filters an existing YmsgObject vector to include only objects matching the criteria
	vector<YmsgItem> filterItemObjects(const vector<YmsgObject>& objects);//filters an existing YmsgObject vector to include only Item-type-objects

	//note: consider making YmsgObject be Data-type as a beginning and allow "parsing" itself into higher-order objects.
	//  (YmsgFieldParser would become YmsgObjectFilter)

	vector<YmsgField> getFields(const string& data);//splits a YMSG data (field data) string into a field objects vector.
	vector<YmsgObject> getObjects(const vector<YmsgField>& fields);//produces a vector of highest-order (list>item>field) as appropriate to represent the input fields
	vector<YmsgObject> getObjects(const string& data);//as above
	vector<YmsgObject> getObjects(const vector<YmsgItem>& items);//outputs a YmsgObject vector containing Item-type-objects
	vector<YmsgObject> getObjects(const vector<YmsgList>& lists);//outputs a YmsgObject vector containing List-type-objects

	void debugObjects(const vector<YmsgObject>& objects);
};

